﻿// Copyright (c) 2010 Dan Popick

// Permission is hereby granted, free of charge, to any person obtaining a copy
// of this software and associated documentation files (the "Software"), to deal
// in the Software without restriction, including without limitation the rights
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
// copies of the Software, and to permit persons to whom the Software is
// furnished to do so, subject to the following conditions:

// The above copyright notice and this permission notice shall be included in
// all copies or substantial portions of the Software.

// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
// THE SOFTWARE.

using System;
using System.Collections.Generic;
using System.Configuration;
using System.Linq;
using System.Text;

namespace Open.Web.Stijl.Configuration
{
    public class StijlConfiguration
    {
        public static StijlConfiguration Default { get; private set; }

        static StijlConfiguration()
        {
            Default = (ConfigurationManager.GetSection("Open.Web.Stijl") as StijlConfiguration) ?? new StijlConfiguration();
        }

		// properties which affect all sprite generation
        public bool Automatic { get; set; }
		public int TiledImageThreshold { get; set; }
		public int RepeatingSolutionLimit { get; set; }

		// properties which are HttpHandler-specific
		public int MaxAge { get; set; }
		public bool DebugMode { get; set; } // turns off caching, compression
		public bool ShowExceptionOutput { get; set; }
		public bool CaseSensitive { get; set; }

		// properties which are Task-specific
		public string OutputDirectoryFormat { get; set; }

        public StijlConfiguration()
        {
			TiledImageThreshold = 50000;
            DebugMode = false;
            Automatic = false;
			ShowExceptionOutput = false;
            MaxAge = 0;
			RepeatingSolutionLimit = 1000;
			CaseSensitive = false;
			OutputDirectoryFormat = "{0}_{1:yyyyMMddHHmmss}_{2}"; // 0 = root filename, 1 = DateTime.Now, 2 = group CRC
        }
    }
}
